﻿using System.Collections.Generic;

namespace 组合模式
{
    //复杂对象
    public class ComplexGraphics: Graphics
    {
        private List<Graphics> _complexGraphicsList = new List<Graphics>();

        public ComplexGraphics(string name) : base(name)
        {
        }

        public override void Draw()
        {
            foreach (var g in _complexGraphicsList)
            {
                g.Draw();
            }
        }
        public void Add(Graphics g)
        {
            _complexGraphicsList.Add(g);
        }
        public void Remove(Graphics g)
        {
            _complexGraphicsList.Remove(g);
        }
    }
}
